<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: 奇辰科技
 * @Date: 2021-12-24 11:25:08
 * @LastEditors: lokei
 * @LastEditTime: 2022-10-04 15:01:57
 */

namespace App\Http\Controllers\Store\Auth;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Store\StoreModel;
use App\Models\Ucenter\UserModel;
use Illuminate\Http\Request;

class AuthController extends Controller
{
    public function bindUser(Request $request)
    {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        if ($request->input('uid') != null && intVal($request->input('uid')) > 0) {
            $store->uid = $request->input('uid');
            $store->save();
            return ResultTool::success();
        } else if ($request->input('mobile') != null) {
            $user = UserModel::where('mobile', '=', $request->input('mobile'))->first();
            if(!is_null($user)) {
                $store->uid = $user->uid;
                $store->save();
                return ResultTool::success();
            }
        }
        $res = ResultTool::fail();
        $res['errorMsg'] = '用户不存在！';
        return $res;
    }
}
